<!--
 * @LastEditors: 杜康
 * @LastEditTime: 2021-09-15 18:02:07
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>联合例子</title>
</head>

<body>
  <div id="app">
    <ele :list="list"></ele>
    <button @click="handleClick">展示列表</button>
  </div>
  <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
  <script>
    Vue.component('ele', {
      render: function (createElement) {
        if (this.list.length) {
          return createElement('ul', this.list.map(function (item) {
            return createElement('li', item)
          }))
        } else {
          return createElement('p', '列表为空')
        }
      },
      props: {
        list: {
          type: Array,
          default: function () {
            return []
          }
          // },
          // show: {
          //   type: Boolean,
          //   default: falses
        }
      }
    })

    var app = new Vue({
      el: '#app',
      data: {
        list: []
        // show: false
      },
      methods: {
        handleClick: function () {
          this.list = [
            'Vuejs 实战',
            'Javascript 高级程序语言',
            'Javascript 语言精粹'
          ]
        }
      }
    })
  </script>
</body>

</html>